﻿<phone:PhoneApplicationPage 
    x:Class="OdcTest.Views.ListBoxPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:bh="clr-namespace:Odyssey.Behaviors;assembly=Odyssey"
    xmlns:ctrls="clr-namespace:Odyssey.Controls;assembly=Odyssey"
    xmlns:fx="clr-namespace:Odyssey.Effects;assembly=Odyssey"
    xmlns:vm="clr-namespace:OdcTest.ViewModels"
    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480" bh:TiltEffect.IsTiltEnabled="True"
    shell:SystemTray.IsVisible="True">

    <d:DesignProperties.DataContext>
        <vm:DataViewModel/>
    </d:DesignProperties.DataContext>

    <phone:PhoneApplicationPage.DataContext>
        <vm:DataViewModel/>
    </phone:PhoneApplicationPage.DataContext>

    <Custom:Interaction.Triggers>
        <Custom:EventTrigger EventName="SelectionChanged" SourceName="listBox">
            <bh:SwingEffectAction/>
            <ic:NavigateToPageAction TargetPage="/Views/DetailPage.xaml?effect=swingFx" />
        </Custom:EventTrigger>
    </Custom:Interaction.Triggers>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="ODYSSEY" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="ListBox" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"  />
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox x:Name="listBox" ItemsSource="{Binding Path=Items}"
                              SelectedItem="{Binding SelectedItem,Mode=TwoWay}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Border Height="80">
                                        <Grid x:Name="grid">
                                            <Rectangle Fill="{StaticResource PhoneChromeBrush}" Width="72" Height="72" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,5"/>
                                            <TextBlock Text="{Binding Name}" 
                                                   FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="90,0,0,0" VerticalAlignment="Center"/>
                                        </Grid>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </Grid>
    </Grid>


</phone:PhoneApplicationPage>